package com.lft.com.oilgas.controller;

import com.lft.com.oilgas.entity.Admin;
import com.lft.com.oilgas.service.impl.AdminServiceImpl;
import com.lft.com.oilgas.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/util/admin")
public class AdminController {
    @Autowired
    private AdminServiceImpl adminService;
    @ExceptionHandler(Exception.class)
    public Result xx(Exception ex) {
        //noinspection CallToPrintStackTrace
        ex.printStackTrace();
        return new Result(false, "服务器异常，等会再试");
    }
    @Transactional
    @RequestMapping("/login")
    public Result login(@RequestBody Admin admin) {
        System.out.println(adminService.login(admin));
        return new Result(true,adminService.login(admin));
    }


}
